package com.powernode.business.controller;

import com.powernode.business.domain.Check;
import com.powernode.business.service.CheckService;
import com.powernode.business.vo.CheckVo;
import com.powernode.common.core.controller.BaseController;
import com.powernode.common.core.domain.AjaxResult;
import com.powernode.common.core.domain.model.LoginUser;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("business/backCar")
@Api(tags = "汽车入库管理")
public class BackCarController extends BaseController {

    @Autowired
    private CheckService checkService;


    @GetMapping("checkRentSn")
    @ApiOperation("根据出租单号查询相关信息")
    public AjaxResult checkRentSn(String rentSn){
        CheckVo checkVo = checkService.checkRentSn(rentSn);
        return AjaxResult.success(checkVo);
    }

    @PostMapping("carBack")
    @ApiOperation("车辆入库")
    public AjaxResult carBack(@RequestBody Check check){
        LoginUser loginUser = getLoginUser();
        check.setOpername(loginUser.getUsername());
        checkService.carBack(check);
        return AjaxResult.success("汽车入库成功");
    }
}
